<?php

namespace app\admin\model\attribute;

use think\exception\ValidateException;
use think\Model;

class BaseSpec extends Model
{
    public static function insertSpec($add){
        try {
           $add['store_id']=session('store_id');

           self::create($add);

                return array(
                    'code' => 200,
                    'msg' => '成功!',
                );

            // dump($result);die;

        } catch (ValidateException $e) {
            // 验证失败 输出错误信息
            return $e->getError();
        }

    }

    public static function modifySpec($add){
        try {
            $result=self::where(['id'=>input('id')])->save($add);

            if(!empty($result)){
                return array(
                    'code' => 200,
                    'msg' => '成功!',
                );
            }else{
                return array(
                    'code' => 40002,
                    'msg' => '失败!',
                );
            }

        } catch (ValidateException $e) {
            // 验证失败 输出错误信息

            return $e->getError();
        }

    }

}